package com.allwees.support.payment.payby.builder;

import com.allwees.core.common.context.SpringContextHolder;
import com.allwees.support.payment.model.RefundInfo;
import com.allwees.support.payment.payby.configuration.PaybyProperties;
import com.payby.gateway.openapi.model.ExternalMoney;
import com.payby.gateway.openapi.request.PlaceRefundOrderRequest;

public class PlaceRefundOrderRequestBuilder {
    private static PaybyProperties paybyProperties = SpringContextHolder.getBean(PaybyProperties.class);

    public static PlaceRefundOrderRequest build(RefundInfo refundInfo) {
        PlaceRefundOrderRequest request = new PlaceRefundOrderRequest();
        // Refund amount Required
        request.setAmount(new ExternalMoney(refundInfo.getAmt(), "AED"));
        // Product name Required
        request.setRefundMerchantOrderNo(refundInfo.getRefundNo());
        // Original merchant order number
        request.setOriginMerchantOrderNo(refundInfo.getOrderNo());
        request.setReserved(refundInfo.getOrderItemUuid());
        request.setNotifyUrl(paybyProperties.getRefundResultNotifyURL());

        return request;
    }
}
